var e = require("../../../../@babel/runtime/helpers/objectSpread2"),
  t = require("../../../../@babel/runtime/helpers/slicedToArray"),
  r = require("../../../../@babel/runtime/helpers/regeneratorRuntime"),
  a = require("../../../../@babel/runtime/helpers/asyncToGenerator"),
  n = require("../../../../store/index"),
  s = require("../../../../utils/index"),
  i = require("../../../../config/index"),
  o = s.helper.tabCommon,
  u = s.helper.listOperate;

function c() {
  return l.apply(this, arguments)
}

function l() {
  return (l = a(r().mark((function a() {
    var s, u, c, l, p, h, f, d, g, m, v;
    return r().wrap((function (r) {
      for (;;) switch (r.prev = r.next) {
        case 0:
          return s = n.store.getState().storage.userLocationCity, u = n.store.getState().storage.userLocation, c = o.getmodeStorageKey(i.typeMode.recruit), l = o.getFilterParamsInfo(c), p = l.type.value, h = l.sort, f = e(e({}, this.parames), {}, {
            page: this.page,
            page_size: 15,
            source: "XCX",
            addr: (null == s ? void 0 : s.id) || 1,
            mode: "5",
            type: 0,
            pattern: (null == h ? void 0 : h.id) || 0
          }), u && (d = u.split(","), g = t(d, 2), m = g[0], v = g[1], Object.assign(f, {
            longitude: m,
            latitude: v
          })), r.abrupt("return", (null != p && p.length && (f.type = p[0].id), f));
        case 3:
        case "end":
          return r.stop()
      }
    }), a, this)
  })))).apply(this, arguments)
}
Component({
  componentPage: {
    onPullDownRefresh: function () {
      this.onRefresh(1).finally((function () {
        wx.stopPullDownRefresh()
      }))
    },
    onReachBottom: function () {
      this.isRefresh || this.data.hasMore || this.data.noData || this.onRefresh(this.page + 1)
    }
  },
  data: {
    firstLoaded: !1,
    list: [],
    loading: !1,
    noData: !1,
    hasMore: !1
  },
  methods: {
    setExtraParames: function (e) {
      var t = this;
      return a(r().mark((function a() {
        return r().wrap((function (r) {
          for (;;) switch (r.prev = r.next) {
            case 0:
              t.parames = e;
            case 1:
            case "end":
              return r.stop()
          }
        }), a)
      })))()
    },
    setRefresh: function (e) {
      var t = this;
      return a(r().mark((function a() {
        return r().wrap((function (r) {
          for (;;) switch (r.prev = r.next) {
            case 0:
              t.isRefresh = e;
            case 1:
            case "end":
              return r.stop()
          }
        }), a)
      })))()
    },
    onRefresh: function () {
      console.log('lklkl')
      var e = arguments,
        n = this;
      return a(r().mark((function a() {
        var s, i, o, l, p, h, f, d, g;
        return r().wrap((function (r) {
          for (;;) switch (r.prev = r.next) {
            case 0:
              return s = e.length > 0 && void 0 !== e[0] ? e[0] : 1, n.page = s, 1 !== s && n.setData({
                loading: !0
              }), r.prev = 2, r.next = 5, c.call(n);
            case 5:
              return i = r.sent, r.next = 8, i.pageNum = i.page, i.keywords ? i.description = i.keywords ? i.keywords : "" : '', i.cityId = i.addr, i.driverTypeId = i.type ? i.type : '', i.userLatitude = i.latitude ? i.latitude : '', i.status = 3, i.userLongitude = i.longitude ? i.longitude : "", i.pageSize = i.page_size, $.request["GET/business/recruit/worker/pageList"](i);
            case 8:
              if (o = r.sent, l = t(o, 1), p = l[0], h = p.data.data,
                p.data.data.map((item) => {
                  item.title = item.description
                  item.mode = 5
                  item.time = item.createTime
                  item.timestamp = Date.parse(item.time) / 1000
                  item.class = [{
                    name: item.driverTypeName
                  }]
                  item.labels = {
                    address: {
                      name: "设备所在地",
                      value: item.provinceText + item.cityText + item.place
                    },
                    distance: {
                      name: "距离",
                      value: (item.distance / 1000).toFixed(2) + "km"
                    }
                  }
                }),
                f = u.getHistoryList(h), 1 !== s || 0 !== f.length) {
                r.next = 15;
                break
              }
              return r.abrupt("return", void n.setData({
                noData: !0,
                list: []
              }));
            case 15:
              if (f.length < 15 ? n.setData({
                  hasMore: !0
                }) : n.setData({
                  hasMore: !1
                }), 1 !== s) {
                r.next = 17;
                break
              }
              return r.abrupt("return", (n.setData({
                list: f.slice(0, 5),
                noData: !1
              }), void setTimeout((function () {
                n.setData({
                  list: n.data.list.concat(f.slice(5)),
                  noData: !1
                })
              }), 200)));
            case 17:
              d = n.data.list.length, g = f.reduce((function (e, t, r) {
                return e["list[".concat(r + d, "]")] = t, e
              }), {
                noData: !1,
                firstLoaded: !0
              }), n.setData(g);
            case 19:
              return r.prev = 19, n.setData({
                loading: !1
              }), !n.data.firstLoaded && setTimeout((function () {
                return n.setData({
                  firstLoaded: !0
                })
              }), 150), r.finish(19);
            case 22:
            case "end":
              return r.stop()
          }
        }), a, null, [
          [2, , 19, 22]
        ])
      })))()
    }
  },
  pageLifetimes: {
    show: function () {
     
    }
  }
});